home *** CD-ROM | disk | FTP | other *** search
/ Komputer for Alle 1999 #5 / 1999 CD 5 (black).iso / Delphi3 / DelphiSv / code.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-02-14  |  1.3 KB  |  62 lines

  1. unit code;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     LblMeddelande: TLabel;
  12.     EdtGissa: TEdit;
  13.     BtnGissa: TButton;
  14.     BtnStart: TButton;
  15.     procedure BtnStartClick(Sender: TObject);
  16.     procedure BtnGissaClick(Sender: TObject);
  17.   private
  18.     { Private declarations }
  19.     Slumpmassig: Integer;
  20.     Foersoek: Integer;
  21.   public
  22.     { Public declarations }
  23.   end;
  24.  
  25. var
  26.   Form1: TForm1;
  27.  
  28. implementation
  29.  
  30. {$R *.DFM}
  31.  
  32. procedure TForm1.BtnStartClick(Sender: TObject);
  33. begin
  34.      randomize;
  35.      Slumpmassig := Random(20);
  36.      Foersoek := 0;
  37.  
  38.      LblMeddelande.Caption := 'Gissa ett tal mellan 1 och 20';
  39.  
  40. end;
  41.  
  42. procedure TForm1.BtnGissaClick(Sender: TObject);
  43. var
  44.    Gissa :Integer;
  45.  
  46. begin
  47.    Gissa := StrToInt(EdtGissa.Text);
  48.    Foersoek := Foersoek + 1;
  49.  
  50.    if Gissa = Slumpmassig then
  51.         LblMeddelande.Caption := 'Du gissade pσ talet  ' +
  52.                                  IntToStr(Foersoek) + '. gΣnger!';
  53.  
  54.    if Gissa < Slumpmassig then
  55.       LblMeddelande.Caption := 'Talet ' + IntToStr(Gissa) + ' Σr mindre Σn "X"';
  56.  
  57.    if Gissa > Slumpmassig then
  58.       LblMeddelande.Caption := 'Talet ' + IntToStr(Gissa) + ' Σr st÷rre Σn "X"';
  59. end;
  60.  
  61. end.
  62.